home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 40
/
Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso
/
Aminet
/
misc
/
emu
/
ATUtilities.lha
/
ATUtilities
/
gb.c
< prev
next >
Wrap
C/C++ Source or Header
|
2000-09-26
|
33KB
|
1,363 lines
/* ******************************************************************* */
/* ** ** */
/* ** ATUtilities HiFi-Player ** */
/* ** Copright (C) 1992-1993 by Thomas Dreibholz ** */
/* ** All rights reserved ** */
/* ** ** */
/* ******************************************************************* */
#include "ATUtilities.h"
#include "HiFi.h"
UBYTE *HelpName="M:xy";
#define MAXTITLES 250
#define CATSIZE (2+(MAXTITLES*128))
struct Catalog
{
UWORD Entries;
UBYTE Title[1][128];
} *Catalog,*Cat2;
struct PlayerList
{
UWORD Entries;
UBYTE Name[100][128];
} PlayerList=
{
3,
"M:DeliPlayers",
"IFF-SMUS",
"IFF-8SVX",
"MarkII"
};
struct Interrupt MyInt;
struct Library *GfxBase;
struct Library *IntuitionBase;
struct Library *ATUtilitiesBase;
struct Library *AslBase;
struct Library *UtilityBase;
struct Library *GadToolsBase;
extern struct Library *SysBase;
extern struct Library *DOSBase;
struct Task *Task;
struct TextFont *opal;
struct Window *HCWindow;
struct Screen *HCScreen;
struct RastPort *HCRPort;
struct ViewPort *HCViewPort;
struct TagItem *ReqTags;
struct FileRequester *FileReq;
struct WBArg *fargs;
struct Lock *lock;
UBYTE dir[130];
struct NewScreen HCScreenDef=
{
0,210,640,45,2,
0,1,HIRES,CUSTOMSCREEN,
0,0,0,0
};
struct NewWindow HCWindowDef=
{
0,0,640,45,0,1,
0L,BORDERLESS,
0L,0L,0L,0L,0L,
50,50,640,100,
CUSTOMSCREEN
};
LONG PortSignal;
ULONG PortSignalMask;
ULONG WaitSignalMask;
ULONG Signale;
VOID HiFiControl();
VOID StopSymbol();
VOID WaitSymbol();
VOID PlaySymbol();
VOID ShowPlayer();
VOID ShowSTitle();
VOID ShowVolume();
VOID ShowInfo();
VOID OpenAll();
VOID CloseAll();
VOID PlayerPrefs();
VOID TitleEd();
VOID LoadCatalog();
VOID SaveCatalog();
BOOL AuPrefs();
struct MsgPort *Port;
struct Global
{
APTR AslBase;
APTR DOSBase;
APTR IntuitionBase;
APTR GfxBase;
APTR GadToolsBase;
APTR ReservedLibraryBase;
APTR DirArrayPtr;
APTR FileArrayPtr;
APTR PathArrayPtr;
APTR ChkData;
ULONG ChkSize;
UWORD SndNum;
UWORD SndVol;
UWORD SndLBal;
UWORD SndRBal;
UWORD LED;
UWORD Timer;
VOID (* GetListData)();
VOID (* LoadFile)();
VOID (* CopyDir)();
VOID (* CopyFile)();
VOID (* CopyString)();
VOID (* AudioAlloc)();
VOID (* AudioFree)();
VOID (* StartInt)();
VOID (* StopInt)();
VOID (* SongEnd)();
VOID (* CutSuffix)();
VOID (* SetTimer)();
APTR R1,R2,R3;
} Global;
struct DOSSegment
{
BPTR NextSegment;
ULONG RTS;
UBYTE ID[8];
APTR TagArray;
};
struct Tag
{
ULONG Code;
ULONG Data;
} *Tags;
struct DOSSegment *Segmente[200];
BPTR Player[200];
UWORD PlayerCnt;
#define TAG_USER 0x80000000
#define TAG_DONE 0
#define TAG_IGNORE 1
#define DPT_TagBase (ULONG)((ULONG)TAG_USER+(ULONG)((UWORD)'DT'))
#define DPT_InternalPlayer DPT_TagBase+0
#define DPT_CustomPlayer DPT_TagBase+1
#define DPT_RequestDTVersion DPT_TagBase+2
#define DPT_RequestV37 DPT_TagBase+3
#define DPT_PlayerVersion DPT_TagBase+4
#define DPT_PlayerName DPT_TagBase+5
#define DPT_Creator DPT_TagBase+6
#define DPT_Check1 DPT_TagBase+7
#define DPT_Check2 DPT_TagBase+8
#define DPT_ExtLoad DPT_TagBase+9
#define DPT_Interrupt DPT_TagBase+10
#define DPT_Stop DPT_TagBase+11
#define DPT_Config DPT_TagBase+12
#define DPT_UserConfig DPT_TagBase+13
#define DPT_SubSoundRange DPT_TagBase+14
#define DPT_InitPlayer DPT_TagBase+15
#define DPT_EndPlayer DPT_TagBase+16
#define DPT_InitSound DPT_TagBase+17
#define DPT_EndSound DPT_TagBase+18
#define DPT_StartInt DPT_TagBase+19
#define DPT_StopInt DPT_TagBase+20
#define DPT_Volume DPT_TagBase+21
#define DPT_Balance DPT_TagBase+22
#define DPT_Faster DPT_TagBase+23
#define DPT_Slower DPT_TagBase+24
#define DPT_NextPatt DPT_TagBase+25
#define DPT_PrevPatt DPT_TagBase+26
#define DPT_NextSong DPT_TagBase+27
#define DPT_PrevSong DPT_TagBase+28
#define DPT_SubSongTest DPT_TagBase+29
WORD CallCheck1(),CallCheck2();
VOID xGetListData();
VOID xLoadFile();
VOID xCopyDir();
VOID xCopyFile();
VOID xCopyString();
VOID xAudioAlloc();
VOID xAudioFree();
VOID xStartInt();
VOID xStopInt();
VOID xSongEnd();
VOID xCutSuffix();
VOID xSetTimer();
APTR InitPlayer;
APTR EndPlayer;
APTR InitSound;
APTR EndSound;
APTR Interrupt;
APTR StartInt;
APTR StopInt;
APTR Check1;
APTR Check2;
APTR Volume;
UBYTE *mem;
UBYTE *pname;
ULONG size;
UWORD current;
BOOL play;
BOOL Start();
VOID Stop();
VOID LoadPlayer();
VOID UnLoadPlayers();
/* Installationsroutine */
VOID main()
{
REGISTER LONG i,j,k,l;
REGISTER BOOL bool;
OpenAll();
bool=FALSE;
play=FALSE;
current=0;
if(HiFiPrefs.Control!=0) HiFiControl();
while(bool==FALSE)
{
Signale=Wait(WaitSignalMask);
if(Signale & PortSignalMask)
{
i=Received(Port);
switch(i)
{
case UTILITY_QUIT:
DisplayBeep(NULL);
if(HCScreen!=NULL) HiFiControl();
bool=TRUE;
break;
case UTILITY_HELP:
Help(HelpName,0);
break;
case UTILITY_INFO:
Stop();
ShowInfo();
break;
case 1100:
if(play==FALSE)
{
current=0;
play=Start(current);
if(play==FALSE) Stop();
}
break;
case 1001:
if(play==FALSE)
{
play=Start(current);
if(play==FALSE) Stop();
}
break;
case 1002:
Stop();
play=FALSE;
break;
case 1003:
Stop();
current=0;
play=Start(0);
if(play==FALSE) Stop();
break;
case 1004:
Stop();
current=Catalog->Entries-1;
play=Start(current);
if(play==FALSE) Stop();
break;
case 1005:
Stop();
current=current+1;
if(current==Catalog->Entries) current=0;
play=Start(current);
if(play==FALSE) Stop();
break;
case 1006:
Stop();
if(current>0) current=current-1; else current=Catalog->Entries-1;
play=Start(current);
if(play==FALSE) Stop();
break;
case 1007:
if(play) Stop();
TitleEd();
play=FALSE;
current=0;
break;
case 1008:
if(play) Stop();
LoadCatalog(NULL);
play=FALSE;
current=0;
break;
case 1009:
if(play) Stop();
SaveCatalog();
if(play)
{
play=Start(current);
if(play==FALSE) Stop();
}
break;
case UTILITY_CALL:
case 1010:
if(play) Stop();
bool=AuPrefs();
if(play)
{
play=Start(current);
if(play==FALSE) Stop();
}
break;
case 1011:
if(play) Stop();
PlayerPrefs();
if(play)
{
play=Start(current);
if(play==FALSE) Stop();
}
break;
case 1012:
HiFiControl();
break;
case 1013:
if(Global.SndVol<=62) Global.SndVol+=2;
if((play)&&(Volume))
CallVolume();
ShowVolume();
break;
case 1014:
if(Global.SndVol>=2) Global.SndVol-=2;
if((play)&&(Volume))
CallVolume();
ShowVolume();
break;
}
}
}
Stop();
CloseAll();
}
/* Installationsroutine */
VOID OpenAll()
{
REGISTER UWORD i;
register struct MsgPort *p;
register struct FileHandle *fh;
p=FindPort(HiFiPort);
if(p!=NULL)
{
InfoRequest("ATUtilities HiFi-Player ist schon aktiv.");
CloseAll();
}
ATUtilitiesBase=OpenLibrary("at-utilities.library",0L);
if(ATUtilitiesBase==NULL)
{
printf("FEHLER: Kann ATUtilities-Library nicht öffnen.\n");
CloseAll();
}
if((SysBase->lib_Version<36)||(DOSBase->lib_Version<36))
{
InfoRequest("HiFi-Player benötigt Kickstart 2.0!");
CloseAll();
}
Task=FindTask(NULL);
GfxBase=OpenLibrary("graphics.library",0L);
IntuitionBase=OpenLibrary("intuition.library",0L);
if((GfxBase==NULL)||(IntuitionBase==NULL))
{
CloseAll();
}
AslBase=OpenLibrary("asl.library",0L);
if(AslBase==NULL)
{
InfoRequest("Konnte Asl-Library nicht laden.");
CloseAll();
}
GadToolsBase=OpenLibrary("gadtools.library",0L);
if(GadToolsBase==NULL)
{
InfoRequest("Konnte GadTools-Library nicht laden.");
CloseAll();
}
UtilityBase=OpenLibrary("utility.library",0L);
if(UtilityBase==NULL)
{
InfoRequest("Konnte Utility-Library nicht laden.");
CloseAll();
}
opal=GetOpalFont();
Port=CreatePort(HiFiPort,0L);
if(Port==NULL)
{
ErrorRequest(ERROR_MPORT);
CloseAll();
}
fh=Open(HiFiPrefsName,MODE_OLDFILE);
if(fh!=NULL)
{
Read(fh,&HiFiPrefs,sizeof(struct HiFiPrefs));
Close(fh);
}
Catalog=AllocMem(CATSIZE*2,MEMF_CLEAR|MEMF_PUBLIC);
if(Catalog==NULL)
{
ErrorRequest(ERROR_ALLOC);
CloseAll();
}
Cat2=(ULONG)Catalog+(ULONG)CATSIZE;
ReqTags=AllocateTagItems(6L);
if(ReqTags==NULL)
{
InfoRequest("Kein Speicher für Tag-Items!\n");
CloseAll();
}
ReqTags[0].ti_Tag=ASL_Pattern;
ReqTags[0].ti_Data="#?";
ReqTags[1].ti_Tag=ASL_FuncFlags;
ReqTags[1].ti_Data=FILF_MULTISELECT|FILF_PATGAD;
ReqTags[2].ti_Tag=ASL_Hail;
ReqTags[2].ti_Data="HiFi-Player - Dateiauswahl";
ReqTags[3].ti_Tag=TAG_DONE;
ReqTags[4].ti_Tag=TAG_DONE;
ReqTags[5].ti_Tag=TAG_DONE;
FileReq=AllocAslRequest(ASL_FileRequest,NULL);
if(FileReq==NULL)
{
InfoRequest("Kein Speicher für ASL-Requester!");
CloseAll();
}
PortSignal=Port->mp_SigBit;
PortSignalMask=(1L<<PortSignal);
WaitSignalMask=PortSignalMask;
ChangeTaskPri(10);
Global.AslBase=AslBase;
Global.DOSBase=DOSBase;
Global.IntuitionBase=IntuitionBase;
Global.GfxBase=GfxBase;
Global.GadToolsBase=GadToolsBase;
Global.SndNum=0;
Global.SndVol=HiFiPrefs.Volume;
Global.SndLBal=HiFiPrefs.LBal;
Global.SndRBal=HiFiPrefs.RBal;
Global.LED=1;
Global.Timer=SysBase->VBlankFrequency;
Global.GetListData=(VOID *)xGetListData;
Global.LoadFile=(VOID *)xLoadFile;
Global.CopyDir=(VOID *)xCopyDir;
Global.CopyFile=(VOID *)xCopyFile;
Global.CopyString=(VOID *)xCopyString;
Global.AudioAlloc=(VOID *)xAudioAlloc;
Global.AudioFree=(VOID *)xAudioFree;
Global.StartInt=(VOID *)xStartInt;
Global.StopInt=(VOID *)xStopInt;
Global.SongEnd=(VOID *)xSongEnd;
Global.CutSuffix=(VOID *)xCutSuffix;
Global.SetTimer=(VOID *)xSetTimer;
MyInt.is_Node.ln_Succ=NULL;
MyInt.is_Node.ln_Pred=NULL;
MyInt.is_Node.ln_Pri=0;
MyInt.is_Node.ln_Type=NT_INTERRUPT;
MyInt.is_Node.ln_Name="hifiplayer.interrupt";
MyInt.is_Data=&Global;
LoadPlayer("M:DeliPlayers/IFF-SMUS");
LoadPlayer("M:DeliPlayers/IFF-8SVX");
LoadPlayer("M:DeliPlayers/MarkII");
LoadCatalog(&HiFiPrefs.DefaultCatalog);
}
/* Programmende */
VOID CloseAll()
{
UnLoadPlayers();
if(HCScreen!=NULL) HiFiControl();
if(Port) DeletePort(Port);
if(ReqTags) FreeTagItems(ReqTags);
if(FileReq) FreeAslRequest(FileReq);
if(Catalog) FreeMem(Catalog,CATSIZE*2);
if(ATUtilitiesBase) CloseLibrary(ATUtilitiesBase);
if(GfxBase) CloseLibrary(GfxBase);
if(IntuitionBase) CloseLibrary(IntuitionBase);
if(UtilityBase) CloseLibrary(UtilityBase);
if(GadToolsBase) CloseLibrary(GadToolsBase);
if(AslBase) CloseLibrary(AslBase);
exit(0);
}
/* Katalog laden */
VOID LoadCatalog(name)
UBYTE *name;
{
Catalog->Entries=16;
strcpy(&Catalog->Title[0],"DH0:Musik/Scores/Aegis Sonix/Strings.smus");
strcpy(&Catalog->Title[1],"DH0:Musik/Scores/Aegis Sonix/The End.smus");
strcpy(&Catalog->Title[2],"DH0:Musik/Scores/Aegis Sonix/The last Fighter.smus");
strcpy(&Catalog->Title[3],"DH0:Musik/Scores/Aegis Sonix/On the Mars.smus");
strcpy(&Catalog->Title[4],"DH0:Musik/Scores/Aegis Sonix/Liveless.smus");
strcpy(&Catalog->Title[5],"DH0:Musik/Scores/Aegis Sonix/Here I am.smus");
strcpy(&Catalog->Title[6],"DH0:Musik/Scores/Aegis Sonix/Begleitung.smus");
strcpy(&Catalog->Title[7],"DH0:Musik/Scores/Aegis Sonix/Danger Planet.smus");
strcpy(&Catalog->Title[8],"DH0:Musik/Scores/Aegis Sonix/Strings.smus");
strcpy(&Catalog->Title[9],"DH0:Musik/Scores/Aegis Sonix/The End.smus");
strcpy(&Catalog->Title[10],"DH0:Musik/Scores/Aegis Sonix/The last Fighter.smus");
strcpy(&Catalog->Title[11],"DH0:Musik/Scores/Aegis Sonix/On the Mars.smus");
strcpy(&Catalog->Title[12],"DH0:Musik/Scores/Aegis Sonix/Liveless.smus");
strcpy(&Catalog->Title[13],"DH0:Musik/Scores/Aegis Sonix/Here I am.smus");
strcpy(&Catalog->Title[14],"DH0:Musik/Scores/Aegis Sonix/Begleitung.smus");
strcpy(&Catalog->Title[15],"DH0:Musik/Scores/Aegis Sonix/Danger Planet.smus");
}
/* Katalog laden */
VOID SaveCatalog()
{
REGISTER UWORD i;
register struct FileHandle *fh;
ReqTags[1].Data=FILF_PATGAD|FILF_SAVE;
if(AslRequest(FileReq,ReqTags))
{
fargs=FileReq->rf_ArgList;
lock=fargs->wa_Lock;
NameFromLock(lock,&dir,80);
i=strlen(&dir)-1;
if(dir[i]!=':') { dir[i+1]='/'; dir[i+2]=0x00; }
strcat(&dir,fargs->wa_Name);
printf("%s\n",&dir);
fh=Open(&dir,MODE_NEWFILE);
if(fh!=NULL)
{
Write(fh,Catalog,CATSIZE);
Close(fh);
}
else
{
MultiRequest("Datei konnte nicht erstellt werden:",
&dir,"Okay",NULL);
}
}
}
/* Information */
VOID ShowInfo()
{
InformationBox("ATUtilities HiFi-Player - Information",
"HiFi-Player - Version 1.0",
"Copyright (C) 1993 by",
"Thomas Dreibholz",
"All rights reserved.",
"SYS:PC/ATUtilities/Icons/HiFi");
}
#asm
public _xGetListData
_xGetListData:
move.l _mem,a0
move.l _size,d0
rts
public _xAudioAlloc
_xAudioAlloc:
clr.l d0
rts
public _xLoadFile
_xLoadFile:
clr.l d0
rts
public _xAudioFree
_xAudioFree:
rts
public _xStartInt
_xStartInt:
rts
public _xStopInt
_xStopInt:
rts
#endasm
VOID xCopyDir()
{
}
VOID xCopyFile()
{
}
VOID xCopyString()
{
}
VOID xSetTimer()
{
}
VOID xCutSuffix()
{
}
VOID xSongEnd()
{
geta4();
Utility(HiFiPort,1005);
}
#asm
public _CallInitPlayer
_CallInitPlayer:
movem.l d1-d7/a0-a6,-(sp)
move.l #_Global,a5
move.l _InitPlayer,a0
jsr (a0)
movem.l (sp)+,d1-d7/a0-a6
rts
public _CallEndPlayer
_CallEndPlayer:
movem.l d1-d7/a0-a6,-(sp)
move.l #_Global,a5
move.l _EndPlayer,a0
jsr (a0)
movem.l (sp)+,d1-d7/a0-a6
rts
public _CallStartInt
_CallStartInt:
movem.l d1-d7/a0-a6,-(sp)
move.l #_Global,a5
move.l _StartInt,a0
jsr (a0)
movem.l (sp)+,d1-d7/a0-a6
rts
public _CallStopInt
_CallStopInt:
movem.l d1-d7/a0-a6,-(sp)
move.l #_Global,a5
move.l _StopInt,a0
jsr (a0)
movem.l (sp)+,d1-d7/a0-a6
rts
public _CallInitSound
_CallInitSound:
movem.l d1-d7/a0-a6,-(sp)
move.l #_Global,a5
move.l _InitSound,a0
jsr (a0)
movem.l (sp)+,d1-d7/a0-a6
rts
public _CallEndSound
_CallEndSound:
movem.l d1-d7/a0-a6,-(sp)
move.l #_Global,a5
move.l _EndSound,a0
jsr (a0)
movem.l (sp)+,d1-d7/a0-a6
rts
public _CallVolume
_CallVolume:
movem.l d1-d7/a0-a6,-(sp)
move.l #_Global,a5
move.l _Volume,a0
jsr (a0)
movem.l (sp)+,d1-d7/a0-a6
rts
public _CallCheck1
_CallCheck1:
movem.l d1-d7/a0-a6,-(sp)
move.l #_Global,a5
move.l _Check1,a0
jsr (a0)
movem.l (sp)+,d1-d7/a0-a6
rts
public _CallCheck2
_CallCheck2:
movem.l d1-d7/a0-a6,-(sp)
move.l #_Global,a5
move.l _Check2,a0
jsr (a0)
movem.l (sp)+,d1-d7/a0-a6
rts
public _FilterOn
_FilterOn:
bclr #1,$bfe001
rts
public _FilterOff
_FilterOff:
bset #1,$bfe001
rts
#endasm
BOOL Start(num)
UWORD num;
{
REGISTER UWORD i,j;
REGISTER BOOL okay,bool;
register struct FileHandle *fh;
if(Catalog->Title[num][0]==0x00) return(FALSE);
WaitSymbol();
ShowSTitle();
okay=FALSE;
fh=Open(&Catalog->Title[num],MODE_OLDFILE);
if(fh!=NULL)
{
Seek(fh,0,OFFSET_END);
size=Seek(fh,0,OFFSET_BEGINNING);
mem=AllocMem(size,MEMF_CHIP|MEMF_CLEAR|MEMF_PUBLIC);
if(mem!=NULL)
{
Read(fh,mem,size);
Global.ChkData=mem;
Global.ChkSize=size;
Global.DirArrayPtr="DF2:";
Global.FileArrayPtr="Strings.smus";
Global.PathArrayPtr=&Catalog->Title[num];
bool=FALSE;
for(j=0;j<PlayerCnt;j++)
{
Tags=Segmente[j]->TagArray;
Check1=GetTagData(DPT_Check1,NULL,Tags);
Check2=GetTagData(DPT_Check2,NULL,Tags);
if(Check1!=NULL)
{
i=CallCheck1();
if(i==0) { bool=TRUE; break; }
}
if(Check2!=NULL)
{
i=CallCheck2();
if(i==0) { bool=TRUE; break; }
}
if((Check1==NULL)&&(Check2==NULL))
{ bool=TRUE; break; }
}
if(bool==TRUE)
{
pname=GetTagData(DPT_PlayerName,"Unbekannt",Tags);
ShowPlayer();
InitPlayer=GetTagData(DPT_InitPlayer,NULL,Tags);
EndPlayer=GetTagData(DPT_EndPlayer,NULL,Tags);
InitSound=GetTagData(DPT_InitSound,NULL,Tags);
EndSound=GetTagData(DPT_EndSound,NULL,Tags);
Interrupt=GetTagData(DPT_Interrupt,NULL,Tags);
StartInt=GetTagData(DPT_StartInt,NULL,Tags);
StopInt=GetTagData(DPT_StopInt,NULL,Tags);
Check1=GetTagData(DPT_Check1,NULL,Tags);
Check2=GetTagData(DPT_Check2,NULL,Tags);
Volume=GetTagData(DPT_Volume,NULL,Tags);
i=0; if(InitPlayer) i=CallInitPlayer();
if(i==0)
{
PlaySymbol();
if((StartInt!=NULL)&&(StopInt!=NULL))
{
CallStartInt();
okay=TRUE;
}
else if((InitSound!=NULL)&&(EndSound!=NULL)&&(Interrupt!=NULL))
{
MyInt.is_Code=Interrupt;
CallInitSound();
AddIntServer(5,&MyInt);
okay=TRUE;
}
}
}
else
{
printf("Kein Player!\n");
}
}
Close(fh);
}
return(okay);
}
VOID Stop()
{
StopSymbol();
pname=NULL;
ShowPlayer();
if(mem!=NULL)
{
if((StartInt!=NULL)&&(StopInt!=NULL))
{
CallStopInt();
if(EndPlayer) CallEndPlayer();
}
else if((InitSound!=NULL)&&(EndSound!=NULL)&&(Interrupt!=NULL))
{
RemIntServer(5,&MyInt);
CallEndSound();
}
FilterOn();
FreeMem(mem,size);
mem=NULL;
}
}
VOID LoadPlayer(name)
UBYTE *name;
{
if(PlayerCnt<199)
Player[PlayerCnt]=LoadSeg(name);
if(Player[PlayerCnt]!=NULL)
{
Segmente[PlayerCnt]=BADDR(Player[PlayerCnt]);
PlayerCnt++;
}
else
{
printf("Fehler bei Player: %s\n",name);
}
}
VOID UnLoadPlayers()
{
REGISTER UWORD i;
if(PlayerCnt>0)
{
for(i=0;i<PlayerCnt;i++)
{
UnLoadSeg(Player[i]);
}
}
}
VOID PlaySymbol()
{
if(HiFiPrefs.Filter!=0) FilterOn(); else FilterOff();
if(HCScreen!=NULL)
{
DrawCNBorder(HCWindow,35,5,50,35);
SetAPen(HCRPort,3);
Move(HCRPort,40,12);
Draw(HCRPort,40,32);
Draw(HCRPort,80,22);
Draw(HCRPort,40,12);
}
}
VOID WaitSymbol()
{
if(HCScreen!=NULL)
{
DrawCNBorder(HCWindow,35,5,50,35);
SetAPen(HCRPort,3);
Move(HCRPort,40,22);
Draw(HCRPort,80,22);
}
}
VOID StopSymbol()
{
if(HCScreen!=NULL)
{
DrawCNBorder(HCWindow,35,5,50,35);
SetAPen(HCRPort,3);
Move(HCRPort,40,12);
Draw(HCRPort,40,32);
Draw(HCRPort,80,32);
Draw(HCRPort,80,12);
Draw(HCRPort,40,12);
}
}
VOID ShowSTitle()
{
if(HCScreen!=NULL)
{
DrawCNBorder(HCWindow,90,5,520,16);
SetAPen(HCRPort,3);
WriteText(HCRPort,100,16,&Catalog->Title[current]);
}
}
VOID ShowPlayer()
{
if(HCScreen!=NULL)
{
DrawCNBorder(HCWindow,90,24,520,16);
if(pname!=NULL)
{
SetAPen(HCRPort,3);
WriteText(HCRPort,100,35,pname);
}
}
}
VOID ShowVolume()
{
REGISTER UWORD v;
if(HCScreen!=NULL)
{
SetAPen(HCRPort,0);
RectFill(HCRPort,616,6,629,39);
v=(Global.SndVol*33)/64;
SetAPen(HCRPort,3);
RectFill(HCRPort,616,39-v,629,39);
}
}
VOID HiFiControl()
{
if(HCScreen==NULL)
{
HCScreen=OpenScreen(&HCScreenDef);
if(HCScreen!=NULL)
{
HCWindowDef.Screen=HCScreen;
HCWindow=OpenWindow(&HCWindowDef);
if(HCWindow!=NULL)
{
HCRPort=HCWindow->RPort;
HCViewPort=ViewPortAddress(HCWindow);
SetRGB4(HCViewPort,0,7,5,8);
SetRGB4(HCViewPort,1,13,13,13);
SetRGB4(HCViewPort,2,2,2,2);
SetRGB4(HCViewPort,3,15,15,5);
SetFont(HCRPort,opal);
ShowSTitle();
ShowPlayer();
DrawCNBorder(HCWindow,615,5,15,35);
if(play) PlaySymbol(); else StopSymbol();
ShowVolume();
return;
}
}
}
if(HCWindow) CloseWindow(HCWindow);
if(HCScreen) CloseScreen(HCScreen);
HCScreen=NULL;
}
BOOL AuPrefs()
{
UBYTE *defCat,*vol,*lbal,*rbal,str[10];
REGISTER UWORD i,j;
REGISTER ULONG Class;
REGISTER BOOL bool,ende;
register struct Window *win;
register struct RastPort *rp;
register struct IntuiMessage *msg;
register struct Gadget *gad;
struct Gadget *filter,*astart,*aswait,*hctrl;
register struct FileHandle *fh;
bool=FALSE;
win=CreateStdWindow("HiFi-Player - Ausgabe-Einstellungen",
75,75,450,108,
CLOSEWINDOW|GADGETUP,
ACTIVATE|WINDOWCLOSE|WINDOWDEPTH|WINDOWDRAG);
if(win!=NULL)
{
rp=win->RPort;
SetFont(rp,opal);
CreateBoolGadget(win,10,15,155,12,"Einstellungen Okay",1);
CreateBoolGadget(win,170,15,155,12,"Programm beenden",2);
CreateBoolGadget(win,335,15,50,12,"Info",3);
CreateBoolGadget(win,390,15,50,12,"Hilfe",4);
WriteText(rp,15,40,"Titel-Katalog bei Programmstart laden:");
defCat=CreateStringGadget(win,10,45,430,10,&HiFiPrefs.DefaultCatalog,127,5);
if(HiFiPrefs.Filter!=0)
filter=CreateSToggleGadget(win,10,60,150,12,"Audio-Filter",6);
else
filter=CreateNToggleGadget(win,10,60,150,12,"Audio-Filter",6);
if(HiFiPrefs.AutoPlaying!=0)
astart=CreateSToggleGadget(win,175,60,130,12,"Auto-Start",7);
else
astart=CreateNToggleGadget(win,175,60,130,12,"Auto-Start",7);
if(HiFiPrefs.AutoPlayingWait!=0)
aswait=CreateSToggleGadget(win,310,60,130,12,"60 Sek. warten",8);
else
aswait=CreateNToggleGadget(win,310,60,130,12,"60 Sek. warten",8);
CreateBoolGadget(win,10,75,150,12,"Player-Module",9);
if(HiFiPrefs.Control!=0)
hctrl=CreateSToggleGadget(win,10,90,150,12,"Kontrolldisplay",12);
else
hctrl=CreateNToggleGadget(win,10,90,150,12,"Kontrolldisplay",12);
sprintf(&str,"%ld",HiFiPrefs.Volume);
vol=CreateIntegerGadget(win,310,75,130,10,&str,3,10);
WriteText(rp,180,83,"Lautstärke:");
WriteText(rp,180,98,"Balance:");
sprintf(&str,"%ld",HiFiPrefs.LBal);
lbal=CreateIntegerGadget(win,310,91,60,10,&str,3,10);
sprintf(&str,"%ld",HiFiPrefs.RBal);
rbal=CreateIntegerGadget(win,380,91,60,10,&str,3,10);
ende=FALSE;
while(ende==FALSE)
{
WaitPort(win->UserPort);
msg=GTGetIMsg(win->UserPort);
Class=msg->Class;
gad=msg->IAddress;
GTReplyIMsg(msg);
switch(Class)
{
case CLOSEWINDOW:
ende=TRUE;
break;
case GADGETUP:
switch(gad->GadgetID)
{
case 1:
fh=Open(HiFiPrefsName,MODE_NEWFILE);
if(fh!=NULL)
{
i=atol(vol);
if(i>64) i=64;
HiFiPrefs.Volume=i;
i=atol(lbal);
if(i>64) i=64;
HiFiPrefs.LBal=i;
i=atol(rbal);
if(i>64) i=64;
HiFiPrefs.RBal=i;
if(hctrl->Flags & SELECTED) HiFiPrefs.Control=1; else HiFiPrefs.Control=0;
if(filter->Flags & SELECTED) HiFiPrefs.Filter=1; else HiFiPrefs.Filter=0;
if(astart->Flags & SELECTED) HiFiPrefs.AutoPlaying=1; else HiFiPrefs.AutoPlaying=0;
if(aswait->Flags & SELECTED) HiFiPrefs.AutoPlayingWait=1; else HiFiPrefs.AutoPlayingWait=0;
strcpy(&HiFiPrefs.DefaultCatalog,defCat);
Write(fh,&HiFiPrefs,sizeof(struct HiFiPrefs));
Close(fh);
}
ende=TRUE;
break;
case 2:
ende=bool=TRUE;
break;
case 3:
ShowInfo();
break;
case 4:
Help(HelpName,0);
break;
case 9:
PlayerPrefs();
break;
}
break;
}
}
DeleteStdWindow(win);
}
return(bool);
}
VOID PlayerPrefs()
{
REGISTER UWORD i,j;
REGISTER ULONG Class;
REGISTER BOOL ende;
register struct Window *win;
register struct RastPort *rp;
register struct IntuiMessage *msg;
register struct Gadget *gad;
win=CreateStdWindow("HiFi-Player - Player-Einstellungen",
25,25,580,150,
CLOSEWINDOW|GADGETUP,
WINDOWCLOSE|WINDOWDEPTH|WINDOWDRAG|ACTIVATE);
if(win!=NULL)
{
rp=win->RPort;
SetFont(rp,GetOpalFont());
CreateBoolGadget(win,10,15,165,12,"Einstellungen okay",1);
CreateBoolGadget(win,210,15,175,12,"Player hinzufügen",2);
CreateBoolGadget(win,395,15,175,12,"Player löschen",3);
DrawNBorder(win,210,30,330,115);
CreatePropGadget(win,545,30,25,115,0,0,0,65535,8);
SelectStdFPen(rp);
WriteText(rp,10,45,"Name:");
DrawNBorder(win,10,50,180,12);
WriteText(rp,10,80,"Version:");
DrawNBorder(win,10,85,180,12);
ende=FALSE;
while(ende==FALSE)
{
WaitPort(win->UserPort);
msg=GTGetIMsg(win->UserPort);
Class=msg->Class;
gad=msg->IAddress;
GTReplyIMsg(msg);
switch(Class)
{
case CLOSEWINDOW:
ende=TRUE;
break;
case GADGETUP:
break;
}
}
DeleteStdWindow(win);
}
}
VOID TitleEd()
{
UBYTE show[10];
UBYTE select[MAXTITLES];
REGISTER UBYTE StdPen;
REGISTER UWORD i,j,k;
REGISTER ULONG Class;
REGISTER BOOL ende,bool;
register struct Window *win;
register struct RastPort *rp;
register struct IntuiMessage *msg;
register struct Gadget *gad,*prop;
register struct PropInfo *pi;
win=CreateStdWindow("HiFi-Player - Titeleditor",
25,25,580,150,
CLOSEWINDOW|GADGETUP,
WINDOWCLOSE|WINDOWDEPTH|WINDOWDRAG|ACTIVATE);
if(win!=NULL)
{
rp=win->RPort;
SetFont(rp,GetOpalFont());
CreateBoolGadget(win,10,15,165,12,"Einstellungen okay",1);
CreateBoolGadget(win,210,15,150,12,"Titel hinzufügen",2);
CreateBoolGadget(win,370,15,150,12,"Titel löschen",3);
CreateBoolGadget(win,525,15,50,12,"Neu",9);
if(Catalog->Entries<=10) j=1; else j=Catalog->Entries-10;
prop=CreatePropGadget(win,545,30,25,115,0,0,0,65535/j,4);
pi=prop->SpecialInfo;
SelectStdFPen(rp);
StdPen=rp->FgPen;
for(i=0;i<Catalog->Entries;i++) select[i]=StdPen;
for( ;i<MAXTITLES;i++) select[i]=0;
for(i=0;i<10;i++) show[i]=i;
i=32; k=0;
for(j=1000;j<1010;j++)
{
CreateMinGadget(win,11,i,528,12,j);
WriteText(rp,15,i+8,&Catalog->Title[k]);
i+=11; k++;
}
DrawNBorder(win,10,30,530,115);
k=0;
ende=FALSE;
while(ende==FALSE)
{
WaitPort(win->UserPort);
msg=GTGetIMsg(win->UserPort);
Class=msg->Class;
gad=msg->IAddress;
GTReplyIMsg(msg);
switch(Class)
{
case CLOSEWINDOW:
ende=TRUE;
break;
case GADGETUP:
switch(gad->GadgetID)
{
case 1:
ende=TRUE;
break;
case 2:
ReqTags[1].Data=FILF_PATGAD|FILF_MULTISELECT;
if((AslRequest(FileReq,ReqTags)))
{
j=FileReq->rf_NumArgs;
if(j>0)
{
fargs=FileReq->rf_ArgList;
while(j--)
{
if(Catalog->Entries<MAXTITLES)
{
lock=fargs->wa_Lock;
NameFromLock(lock,&dir,80);
i=strlen(&dir)-1;
if(dir[i]!=':') { dir[i+1]='/'; dir[i+2]=0x00; }
strcpy(&Catalog->Title[Catalog->Entries],&dir);
strcat(&Catalog->Title[Catalog->Entries],fargs->wa_Name);
Catalog->Entries++;
} else DisplayBeep(NULL);
fargs++;
}
for(i=0;i<Catalog->Entries;i++) select[i]=StdPen;
for( ;i<MAXTITLES;i++) select[i]=0;
for(i=0;i<10;i++) show[i]=i;
i=32;
DrawCNBorder(win,10,30,530,115);
for(k=0;k<10;k++)
{
if(k<Catalog->Entries)
{
WriteText(rp,15,i+8,&Catalog->Title[k]);
i+=11;
} else break;
}
if(Catalog->Entries<=10) j=1; else j=Catalog->Entries-10;
ModifyProp(prop,win,NULL,
PROPBORDERLESS|FREEVERT|AUTOKNOB,
0,0,0,65535/j);
}
}
break;
case 9:
bool=MultiRequest("Wollen Sie wirklich alle einen neuen",
"Katalog erstellen?",
"Ja, Erstellen","Nein, Abbruch");
if(bool==TRUE)
{
bool=MultiRequest("Wollen Sie eventuelle Änderungen im aktuellen",
"Titelkatalog abspeichern oder verwerfen?",
"Abspeichern","Verwerfen");
if(bool==TRUE) SaveCatalog();
k=0;
DrawCNBorder(win,10,30,530,115);
for(i=0;i<Catalog->Entries;i++) select[i]=StdPen;
for( ;i<MAXTITLES;i++) select[i]=0;
for(i=0;i<10;i++) show[i]=i;
for(i=0;i<MAXTITLES;i++) Catalog->Title[i][0]=0x00;
ModifyProp(prop,win,NULL,
PROPBORDERLESS|FREEVERT|AUTOKNOB,
0,0,0,65535);
}
break;
case 3:
bool=MultiRequest("Wollen Sie wirklich alle gewählten",
"Titel aus dem Katalog löschen?",
"Ja, Löschen","Nein, Abbruch");
if(bool==TRUE)
{
j=0;
for(i=0;i<Catalog->Entries;i++)
{
if(select[i]!=3)
{
strcpy(&Cat2->Title[j],&Catalog->Title[i]); j++;
}
}
Cat2->Entries=j;
for( ;j<MAXTITLES;j++) Cat2->Title[j][0]=0x00;
CopyMem(Cat2,Catalog,CATSIZE);
DrawCNBorder(win,10,30,530,115);
for(i=0;i<Catalog->Entries;i++) select[i]=StdPen;
for( ;i<MAXTITLES;i++) select[i]=0;
for(i=0;i<10;i++) show[i]=i;
i=32;
for(k=0;k<10;k++)
{
if(k<Catalog->Entries)
{
WriteText(rp,15,i+8,&Catalog->Title[k]);
i+=11;
} else break;
}
if(Catalog->Entries<=10) j=1; else j=Catalog->Entries-10;
ModifyProp(prop,win,NULL,
PROPBORDERLESS|FREEVERT|AUTOKNOB,
0,0,0,65535/j);
}
break;
case 4:
if(Catalog->Entries>10)
{
j=pi->VertPot/(65535/(Catalog->Entries-10));
if(j!=k)
{
k=j;
DrawCNBorder(win,10,30,530,115);
for(i=0;i<10;i++)
{
show[i]=k+i;
SetAPen(rp,select[show[i]]);
WriteText(rp,15,40+(i*11),&Catalog->Title[k+i]);
}
}
}
break;
default:
if((gad->GadgetID>=1000)&&(gad->GadgetID<1010))
{
j=gad->GadgetID-1000;
if(select[show[j]]!=0)
{
if(select[show[j]]!=3)
select[show[j]]=3;
else
select[show[j]]=StdPen;
SetAPen(rp,select[show[j]]);
WriteText(rp,15,40+(j*11),&Catalog->Title[show[j]]);
}
}
break;
}
break;
}
}
DeleteStdWindow(win);
}
}